from flask import Flask
from flask import render_template

app = Flask(__name__)
books = {
    "古典":[{"book_name": "《三字经》", "book_type": "必读", "author": "朋朋", "public": "延边出版社", "class": "古典"},
          {"book_name": "《百家姓》", "book_type": "选读", "author": "嘟嘟", "public": "清华出版社", "class": "古典"},
          {"book_name": "《论语》", "book_type": "必读", "author": "孔子", "public": "人民出版社", "class": "古典"},
          {"book_name": "《资治通鉴》", "book_type": "选读", "author": "浩浩", "public": "油田出版社", "class": "古典"},
          {"book_name": "《本草纲目》", "book_type": "必读", "author": "李时珍", "public": "同济大学出版社", "class": "古典"},
          ],
    "当代":[{"book_name": "《坏蛋是怎样炼成的》", "book_type": "选读", "author": "六道", "public": "新华出版社", "class": "当代"},
            {"book_name": "《斗罗大陆》", "book_type": "必读", "author": "谁道了", "public": "北京出版社", "class": "当代"},
            {"book_name": "《武动乾坤》", "book_type": "选读", "author": "谁道了", "public": "新华出版社", "class": "当代"},
            {"book_name": "《诛仙》", "book_type": "必读", "author": "忘记了", "public": "北京出版社", "class": "当代"},
          ],
    "文学":[{"book_name": "《钢铁是怎样炼成的》", "book_type": "必读", "author": "列夫", "public": "上海交大出版社", "class": "文学"},
            {"book_name": "《骆驼祥子》", "book_type": "必读", "author": "老舍", "public": "北京交大出版社", "class": "文学"},
            {"book_name": "《茶馆》", "book_type": "必读", "author": "老舍", "public": "西安交大出版社", "class": "文学"},
            {"book_name": "《四世同堂》", "book_type": "必读", "author": "老舍", "public": "西安交大出版社", "class": "文学"},
          ],
    "经典":[{"book_name": "《鹿鼎记》", "book_type": "选读", "author": "古龙", "public": "清华大学出版社", "class": "经典"},
            {"book_name": "《倚天屠龙记》", "book_type": "选读", "author": "金庸", "public": "北京大学出版社", "class": "经典"},
            {"book_name": "《天涯明月刀》", "book_type": "选读", "author": "金庸", "public": "同济大学出版社", "class": "经典"},
            {"book_name": "《射雕英雄传》", "book_type": "选读", "author": "查良镛", "public": "清华大学出版社", "class": "经典"}],
    "武侠":[{"book_name": "《庆余年》", "book_type": "必读", "author": "猫腻", "public": "中公出版社", "class": "武侠"},
            {"book_name": "《甄嬛传》", "book_type": "必读", "author": "猫腻", "public": "华图出版社", "class": "武侠"},
            {"book_name": "《康熙王朝》", "book_type": "必读", "author": "猫腻", "public": "黑马出版社", "class": "武侠"},
            {"book_name": "《明朝那些事儿》", "book_type": "必读", "author": "猫腻", "public": "未知出版社", "class": "武侠"}]
}


@app.route("/book_list/<cls>/")
def book_list(cls):
    print(books.get(cls))
    return render_template("book_list.html",books=books.get(cls))


if __name__ == '__main__':
    app.run(
        host="127.0.0.1",
        port=80,
        debug=True
    )
